from extension import db  # 防止循环引用


class Animal(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    nickname = db.Column(db.String(255), nullable=False)
    sex = db.Column(db.String(255), nullable=False)
    type = db.Column(db.String(255), nullable=False)
    age = db.Column(db.String(255), nullable=False)
    img = db.Column(db.String(255), nullable=False)
    address = db.Column(db.String(255), nullable=False)
    status = db.Column(db.String(255), nullable=False)
    sterilization = db.Column(db.String(255), nullable=False)
    vaccine = db.Column(db.String(255), nullable=False)
    adopt = db.Column(db.String(255), nullable=False)
    information = db.Column(db.String(255), nullable=False)
    is_adopt = db.Column(db.String(255), nullable=False)
    praise = db.Column(db.Integer, default=0)

    def to_dict(self):
        return {
            'id': self.id,
            'nickname': self.nickname,
            'sex': self.sex,
            'type': self.type,
            'age': self.age,
            'img': self.img,
            'address': self.address,
            'status': self.status,
            'sterilization': self.sterilization,
            'vaccine': self.vaccine,
            'adopt': self.adopt,
            'information': self.information,
            'is_adopt': self.is_adopt,
            'praise': self.praise
        }
